package c.a.a.d0;

import c.a.a.d0.h0.c;
import c.a.a.d0.h0.c.a;
import c.a.a.d0.h0.c.b;
import c.a.a.f;
import c.a.a.z.c.h;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/* compiled from: KeyframesParser */
public class q {
    public static a a = a.a("k");

    public static <T> List<c.a.a.f0.a<T>> a(c cVar, f fVar, float f, g0<T> g0Var) throws IOException {
        ArrayList arrayList = new ArrayList();
        if (cVar.u0() == b.STRING) {
            fVar.a("Lottie doesn't support expressions.");
            return arrayList;
        }
        cVar.o();
        while (cVar.t()) {
            if (cVar.w0(a) != 0) {
                cVar.y0();
            } else if (cVar.u0() == b.BEGIN_ARRAY) {
                cVar.n();
                if (cVar.u0() == b.NUMBER) {
                    arrayList.add(p.a(cVar, fVar, f, g0Var, false));
                } else {
                    while (cVar.t()) {
                        arrayList.add(p.a(cVar, fVar, f, g0Var, true));
                    }
                }
                cVar.q();
            } else {
                arrayList.add(p.a(cVar, fVar, f, g0Var, false));
            }
        }
        cVar.r();
        b(arrayList);
        return arrayList;
    }

    public static <T> void b(List<? extends c.a.a.f0.a<T>> list) {
        int i;
        int size = list.size();
        int i2 = 0;
        while (true) {
            i = size - 1;
            if (i2 >= i) {
                break;
            }
            c.a.a.f0.a aVar = (c.a.a.f0.a) list.get(i2);
            i2++;
            c.a.a.f0.a aVar2 = (c.a.a.f0.a) list.get(i2);
            aVar.f = Float.valueOf(aVar2.e);
            if (aVar.c == null) {
                Object obj = aVar2.b;
                if (obj != null) {
                    aVar.c = obj;
                    if (aVar instanceof h) {
                        ((h) aVar).e();
                    }
                }
            }
        }
        c.a.a.f0.a aVar3 = (c.a.a.f0.a) list.get(i);
        if ((aVar3.b == null || aVar3.c == null) && list.size() > 1) {
            list.remove(aVar3);
        }
    }
}
